//
//  AppDelegate.m
//  BSHOUYIFANG
//
//  Created by 曹雁彬 on 15/8/13.
//  Copyright (c) 2015年 CYB. All rights reserved.
//

#import "AppDelegate.h"
#import "Header.h"
#import "SYFileHandle.h"
#import <SMS_SDK/SMSSDK.h>
//#import <TencentOpenAPI/TencentApiInterface.h>

@interface AppDelegate ()<UITabBarControllerDelegate>
/**
 *  新代码
 */
/**
 *  sf
 */
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    [NSThread sleepForTimeInterval:1];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
 
    //[[SYFileHandle shareInstance] setloginState:NO];
    SYHomeTableViewController *homeVC = [[SYHomeTableViewController alloc]initWithStyle:UITableViewStyleGrouped];
    UINavigationController *homeNVC = [[UINavigationController alloc]initWithRootViewController:homeVC];
    homeNVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"首 页" image:[UIImage imageNamed:@"tb_tutorial@3x"] tag:1001];
    
    SYMyViewController *meVC = [[SYMyViewController alloc]init];
    UINavigationController *meNVC = [[UINavigationController alloc]initWithRootViewController:meVC];
    meNVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我 的" image:[UIImage imageNamed:@"tb_personal@3x"] tag:1002];
    
    SYMomentsViewController *momentsVC = [[SYMomentsViewController alloc]init];
    UINavigationController *momentsNVC = [[UINavigationController alloc]initWithRootViewController:momentsVC];
    momentsNVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"课 堂" image:[UIImage imageNamed:@"tb_hand-ring@3x"] tag:1003];
    
    SYCourseTableViewController *courseVC = [[SYCourseTableViewController alloc]initWithStyle:UITableViewStylePlain];
  
    UINavigationController *courseNVC = [[UINavigationController alloc]initWithRootViewController:courseVC];
    courseNVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"精 品" image:[UIImage imageNamed:@"tb_class"] tag:1004];
    
    UITabBarController *SYController = [[UITabBarController alloc]init];
    SYController.viewControllers = @[homeNVC,momentsNVC,courseNVC,meNVC];
    self.window.rootViewController = SYController;
    SYController.selectedIndex = 0;
    SYController.delegate = self;
  
   
    SYController.tabBar.barTintColor =[UIColor colorWithRed:41/255.0 green:41/255.0 blue:41/255.0 alpha:0.8];//tabBar的颜色
    
    UIColor *color = [UIColor colorWithRed:230/255.0 green:61/255.0 blue:60/255.0 alpha:0.8];
    [[UINavigationBar appearance]setBarTintColor:color];
    
    
    [SMSSDK registerApp:@"9d14cc1d6b96" withSecret:@"84fae568dae98027a07960645c3cb23d"];
    
    
    
    /**
     *  qq快捷登陆
     */
    
    

   
    
    
    
    [self.window makeKeyAndVisible];
    
    /**
     开机动画
     :returns:
     */
    
    UIImageView *splashView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    //将图片添加到UIImageView对象中
    splashView.image=[UIImage imageNamed:@"qd23"];
    
    UIImageView *titleView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH+200, 70)];
    titleView.center = CGPointMake(SCREEN_WIDTH/2+5, SCREEN_HEIGHT-60);
    titleView.image = [UIImage imageNamed:@"title"];
    [self.window addSubview:splashView];
    [self.window addSubview:titleView];
    [self.window bringSubviewToFront:splashView];
    [self.window bringSubviewToFront:titleView];
    //设置动画效果
//    [UIView beginAnimations:nil context:nil];
    [UIView animateWithDuration:3 delay:0.6 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
        splashView.frame=CGRectMake(-60, -90, 450, 800);
    } completion:^(BOOL finished) {
        splashView.alpha = 0.0;
        titleView.alpha = 0.0;
    }];
    

    return YES;
}

//openURL:
//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
////    return [TencentOAuth HandleOpenURL:url];
//}

//handleOpenURL:
//- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
//    return [TencentOAuth HandleOpenURL:url];
//}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
